import request from './request'

//获取数据
export const getGoodsApi = () => {
  return request({
    url: '/goods',
    method: 'GET',
  })
}

//获取指定id数据
export const getGoodsByIdApi = (id) => {
  return request({
    url: `/goods/${id}`,
    method: 'GET',
  })
}

//添加数据
export const addGoodsApi = (name, price) => {
  return request({
    url: '/goods',
    method: 'POST',
    data: {
      name: name,
      price: price,
    },
  })
}

//修改数据
export const editGoodsApi = (id, name, price) => {
  return request({
    url: `/goods/${id}`,
    method: 'PUT',
    data: {
      name: name,
      price: price,
    },
  })
}

//删除数据
export const deleteGoodsApi = (id) => {
  return request({
    url: `/goods/${id}`,
    method: 'DELETE',
  })
}
